/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

/**
 * <p>Project: javase2203 - C4
 * <p>Powered by webrx On 2022-07-19 11:34:38
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class C4 {
    static {
        for (int i = 0; i < 3; i++) {
            System.out.printf("static 1 %d %n", i);
        }
    }


    {
        for (int i = 0; i < 6; i++) {
            System.out.printf("初始化 2 %d %n", i);
        }
    }

    public static void main(String[] args) {
        //C4 默认执行了静态程序块

        C4 c = new C4();  //当第一次实例化时，先执行静态程序块 再执行初始化程序块
        System.out.println("--------------------------------------------------------");
        C4 cc = new C4();

    }

    {
        for (int i = 0; i < 6; i++) {
            System.out.printf("初始化 1 %d %n", i);
        }
    }

    static{
        for (int i = 0; i < 5; i++) {
            System.out.printf("静态程序块 2 %d %n", i);
        }
        int a = 10;
        int b = 20;
        System.out.printf("%d + %d = %d %n",a,b,a+b);
    }
}
